#!/usr/bin/make -f

DESTDIR=$(CURDIR)/debian/posix-locales

locale_set=fr_FR en_GB en_US fi_FI ru_RU es_ES es_MX de_DE nl_NL da_DK el_GR no_NO sv_SE pt_PT it_IT pl_PL cs_CZ \
           de_CH fr_CH it_CH el_CY tr_CY en_IE hu_HU ro_RO sk_SK et_EE lv_LV lt_LT is_IS de_AT hr_HR sr_RS sl_SI \
           bg_BG mt_MT nl_BE fr_BE de_BE fr_LU mk_MK sr_ME bs_BA ar_AE ar_SA ar_KW ar_QA ar_BH ar_OM uk_UA en_AU \
           en_SG id_ID th_TH en_PH ms_MY vi_VN ne_NP en_NZ fa_IR ar_IQ ar_JO ar_LB ar_SY ur_PK ar_EG ar_LY en_NG \
           ar_SD ar_DZ ar_MA ar_TN so_KE lg_UG en_ZA en_IN en_HK fr_CA en_CA zh_TW kk_KZ km_KH lo_LA si_LK en_NE \
           en_GH en_MD en_TZ en_MZ

build: build-stamp
build-stamp:
	mkdir -p $(CURDIR)/build
	@for i in $(locale_set); do \
	  echo -n "Building locale $$i (UTF-8) ..."; \
	  I18NPATH=$(CURDIR)/locales/ localedef --quiet -c \
	    --charmap=$(CURDIR)/charmaps/UTF-8 --inputfile=$$i build/$$i; \
	  echo " done."; \
	done
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	rm -rf build
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	
	@for i in $(locale_set); do \
	  echo "Installing locale $$i (UTF-8)"; \
	  mkdir -p $(DESTDIR)/usr/lib/locale/$$i; \
	  localedef --prefix=$(DESTDIR)/ --add-to-archive build/$$i; \
	done

binary-indep:

binary-arch: install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_fixperms
	dh_compress
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch

.PHONY: build clean binary-indep binary-arch binary install

